<template>
  <div :class="['StickyHeader', { show:show }]">
    <div class="container">
      <a class="logo" href="javascript:;"></a>
      <Nav></Nav>
      <div class="right">
        <router-link to="">品牌</router-link>
        <router-link to="">专题</router-link>
      </div>
    </div>
  </div>
</template>

<script>
import Nav from "./Nav.vue";
export default {
  name: "StickyHeader",
  data(){
    return{
      show:false
    }
  },
  components: {
    Nav,
  },
  mounted() {
    window.addEventListener("scroll", () => {
      let scrollTop =document.documentElement.scrollTop || document.body.scrollTop;
      if (scrollTop > 53) {
        this.show = true;
      } else {
        this.show = false;
      }
    });
  },
};
</script>
<style scoped lang="less">

.StickyHeader {
  background: white;
  position: fixed;
  top: -81px;
  left: 0;
  width: 100%;
  z-index: 999;
  transition: all 0.3s linear;
  border-bottom: 1px solid #e4e4e4;
  .container {
    position: relative;
    display: flex;
    align-items: center;
    .logo {
      display: block;
      width: 200px;
      height: 80px;
      background: url(http://erabbit.itheima.net/img/logo.0940ebb5.png)
        no-repeat right 2px;
      background-size: 160px auto;
    }

    .right {
      width: 220px;
      display: flex;
      text-align: center;
      padding-left: 40px;
      border-left: 2px solid #27ba9b;
      box-sizing: border-box;
      & > a:hover {
        color: #27ba9b;
      }
      a {
        color: #333;
        width: 38px;
        margin-right: 40px;
        font-size: 16px;
        line-height: 1;
      }
    }
  }
}
.show {
  top: 0;
}
</style>